﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using AppShare.Data.Models;

namespace AppShare.Web
{
    public sealed partial class ShipData
    {
        [Key]
        public int ShipId { get; set; }

        public string ShipName { get; set; }
        public DateTime LastUpdated { get; set; }
        public string ED2K { get; set; }

        public string FileName { get; set; }
        public DateTime PublishDate { get; set; }
        public string CRC { get; set; }
        public string SHA1 { get; set; }
        public string FileSize { get; set; }

        public bool IsAvailable { get; set; }

        public static ShipData FromItem(Item t)
        {
            return new ShipData()
            {
                ShipId = (int)t.ID,

                ShipName = t.DetailsName,
                LastUpdated = t.LastUpdate.Value,
                ED2K = t.ed2k,

                FileName = t.FileName,
                PublishDate = t.DatePosted.Value,
                CRC = t.ISOCRC,
                SHA1 = t.SHA1,
                FileSize = t.FileLengthDisplay,

                IsAvailable = t.Availabilty,
            };
        }
    }
}